/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package blackjack;

import java.util.*;

/**
 *
 * @author ronricha
 */
public class StandardHand implements Hand {

    private LinkedList<PlayingCard> hand = new LinkedList();

    public void addCard(PlayingCard card) {
        hand.add(card);
    }

    public String asObscuredString() {
        String returnObscuredString = "? of ?\n";
        for (int i = 1; i < hand.size(); i++) {
            returnObscuredString += hand.get(i).getRank().toString() + " of " + hand.get(i).getSuit().toString() + "\n";
        }
        return returnObscuredString;
    }

    public String asString() {
        String returnAsString = "";
        for (PlayingCard card : hand) {
            returnAsString += card.getRank().toString() + " of " + card.getSuit().toString() + "\n";
        }
        return returnAsString;
    }

    public int getValue() {
        int cardValue = 0;
        for (PlayingCard card : hand) {
            if (card.getRank().toString() == "Two") {
                cardValue += 2;
            } else {
                if (card.getRank().toString() == "Three") {
                    cardValue += 3;
                } else {
                    if (card.getRank().toString() == "Four") {
                        cardValue += 4;
                    } else {
                        if (card.getRank().toString() == "Five") {
                            cardValue += 5;
                        } else {
                            if (card.getRank().toString() == "Six") {
                                cardValue += 6;
                            } else {
                                if (card.getRank().toString() == "Seven") {
                                    cardValue += 7;
                                } else {
                                    if (card.getRank().toString() == "Eight") {
                                        cardValue += 8;
                                    } else {
                                        if (card.getRank().toString() == "Nine") {
                                            cardValue += 9;
                                        } else {
                                            if (card.getRank().toString() == "Ten") {
                                                cardValue += 10;
                                            } else {
                                                if (card.getRank().toString() == "Jack") {
                                                    cardValue += 10;
                                                } else {
                                                    if (card.getRank().toString() == "Queen") {
                                                        cardValue += 10;
                                                    } else {
                                                        if (card.getRank().toString() == "King") {
                                                            cardValue += 10;
                                                        } else {
                                                            if (card.getRank().toString() == "Ace") {
                                                                cardValue += 1;
                                                                if ((cardValue += 11) < 21) {
                                                                    cardValue += 11;
                                                                } else {
                                                                    cardValue += 1;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return cardValue;
    }
}

